home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / OS⁄Toolbox / DeferCrsr / DeferCrsr2.a < prev   
Encoding:
Text File  |  1990-03-12  |  2.6 KB  |  82 lines  |  [TEXT/MPS ]

  1. ***********************************************************************
  2. ***     
  3. ***     Defer Cursor
  4. ***     This program defers the cursor updating that normally happens
  5. ***     during slot VBL time. Since the cursor updating can take as
  6. ***     long as 900µSec, and holds off other slot interrupts, it is
  7. ***     handy to be able to defer the updating to a more civilized time.
  8. ***     This program replaces the normal jCrsrTask with a routine that
  9. ***     installs the real jCrsrTask routine as a deferred task.
  10. ***
  11. ***        8/14/89 Re-wrote DeferCrsr.a to use the deferred task manager.
  12. ***     
  13. ***     Build commands:
  14. ***
  15. ***     asm DeferCrsr.a -lo DeferCrsr.a.lst -l
  16. ***     link DeferCrsr.a.o -o DeferCrsr
  17. ***
  18. ***********************************************************************
  19.  
  20.                     STRING    ASIS
  21.                     PRINT    OFF
  22.                     INCLUDE 'Traps.a'
  23.                     INCLUDE 'SysEqu.a'
  24.                     PRINT    ON
  25.  
  26. ******************************** Entry *******************************
  27.  
  28. Entry    MAIN
  29.  
  30.         bra.s            Entry2
  31.         
  32. ****************************** MyDefTask *****************************
  33.  
  34. TaskBegin
  35. MyDefTask
  36.         
  37.         DC.L    0    ;qLink (handled by OS)
  38.         DC.W    0    ;qType (equ 7, find this value in MPW AIncludes)
  39.         DC.W    0    ;dtFlags (reserved, don't mess with 'em)
  40.         DC.L    0    ;dtAddr (pointer to actual routine to be performed)
  41.         DC.L    0    ;dtParm (optional parameter, this example doesn't use it)
  42.         DC.L    0    ;dtReserved (should be zero, DC.L 0 takes care of that)
  43.         
  44. SysCrsrTask
  45.         DC.L    0
  46.         
  47. ***************************** MyjCrsrTask ****************************
  48.  
  49. MyjCrsrTask
  50.         movem.l        a0/d0,-(sp)
  51.         lea            MyDefTask,a0                    ;point to our deferred task element
  52.         move.l        SysCrsrTask,dtAddr(a0)            ;set up pointer to routine
  53.         move.w        #dtQType,dtType(a0)                ;set queue type
  54.         _DTInstall                                    ;install the task
  55.         movem.l        (sp)+,a0/d0
  56.         rts
  57. TaskEnd
  58.  
  59. ******************************** Entry2 ******************************
  60.  
  61. TaskSize    EQU        TaskEnd-TaskBegin
  62.  
  63. Entry2        
  64.         move.l        #TaskSize,d0                ;TaskSize = Deferred task element, room for
  65.                                                 ; a pointer (to original jCrsrTask), and
  66.                                                 ;our jCrsrTask
  67.         _NewPtr        ,SYS,CLEAR                    ;make a block in the system heap
  68.         bne.s        Abort                        ;no room at the Inn, head for the manger
  69.         move.l        a0,a2                        ;got a good pointer, keep a copy
  70.         move.l        a0,a1                        ;a0 = source, a1 = destination for BlockMove
  71.         lea            MyDEFTask,a0                ;copy the task, etc. into the system heap
  72.         move.w        #TaskSize,d0
  73.         _BlockMove
  74.         
  75.         lea            dtQElSize(a2),a0            ;move original jCrsrTask pointer into our 
  76.         move.l        jCrsrTask,(a0)                ; pointer holder
  77.         lea            dtQElSize+4(a2),a0            ;replace jCrsrTask pointer with a pointer 
  78.         move.l        a0,jCrsrTask                ; to our jCrsrTask
  79.                         
  80. abort    rts                                        ;all's well that ends…
  81.  
  82.         END